package com.dtflys.forest.example.amap.controller;

import com.dtflys.forest.example.amap.client.AmapClient;
import com.dtflys.forest.example.amap.vo.GeoResultVo;
import com.dtflys.forest.example.amap.vo.RegeoResultVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.websocket.server.PathParam;

/**
 * 高德地图测试 API
 *
 * @author gongjun[dt_flys@hotmail.com]
 * @since 2021-10-19 22:37
 */
@RestController
public class AmapController {

    @Resource
    private AmapClient amapClient;

    @GetMapping("/geocode/{city}/{address}")
    public GeoResultVo findGeocodeByAddressAndCity(
            @PathVariable("address") String address,
            @PathVariable("city") String city) {
        GeoResultVo resultVo = amapClient.findGeocodeByAddress(address, city);
        return resultVo;
    }


    @GetMapping("/geocode/{address}")
    public GeoResultVo findGeocodeByAddress(@PathVariable("address") String address) {
        GeoResultVo resultVo = amapClient.findGeocodeByAddress(address);
        return resultVo;
    }

    @GetMapping("/regeocode")
    public RegeoResultVo findRegeocode(@PathParam("latitude") String latitude, @PathParam("latitude") String longitude, @PathParam("radius") Integer radius) {
        RegeoResultVo resultVo = amapClient.findRegeocode(latitude, longitude, radius);
        return resultVo;
    }


}
